package com.fla.millioner.ui.support;

import android.util.Base64;

public class Cencrypt {
    public static String decrypt(String str, String key) {
        return applyAlgorithm(new String(Base64.decode(str, 0)), key);
    }

    private static String applyAlgorithm(String str, String key) {
        StringBuffer sb = new StringBuffer(str);

        int lenStr = str.length();
        int lenKey = key.length();

        for (int i = 0, j = 0; i < lenStr; i++, j++) {
            if (j >= lenKey)
                j = 0;
            sb.setCharAt(i, (char) (str.charAt(i) ^ key.charAt(j)));
        }
        return sb.toString();
    }
}
